<?php
/**
 * 系统设置: 平台
 * User: bgl
 * Date: 2022/9/7
 * Time: 10:09
 */

namespace App\Admin\Controllers\Basics;

use App\Models\Basics\SysPlat;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;

class SysPlatController extends AdminController{

    protected $title = '平台设置';

    protected function grid()
    {
        $grid = new Grid(new SysPlat());
        $grid->column('id', 'ID');
        $grid->column('plat_id', '平台id');
        $grid->column('title', '名称名称');
        $grid->column('sketch', '简述');

        $grid->actions(function (Grid\Displayers\Actions $actions) {
            $actions->disableView();
            $actions->disableDelete();
        });

        $grid->disableRowSelector();
        $grid->disableExport();
        $grid->disableFilter();
        $grid->quickSearch('plat_id', 'title');

        return $grid;
    }

    public function form()
    {
        $form = new Form(new SysPlat());

        $form->hidden('id');
        $form->text('plat_id', '平台id')->required()->rules('required', ['required' => '平台id不能为空'])->width('60%');
        $form->text('title', '平台名称')->required()->rules('required', ['required' => '平台名称不能为空'])->width('60%');
        $form->text('sketch', '平台简述')->width('60%');
        $form->tools(function (Form\Tools $tools) {
            $tools->disableView();
            $tools->disableDelete();
        });
        return $form;
    }

}
